CMAKE_MINIMUM_REQUIRED( VERSION 3.8 )

################################################################################
#
#  设置项目名称
#

PROJECT(
    ha-test
    LANGUAGES CXX C
    VERSION 0.1.1
)

################################################################################
#
#  设置构建类型
#       二进制： SET( BUILD_RULES EXECUTABLE )
#       静态库： SET( BUILD_RULES STATIC )
#       动态库： SET( BUILD_RULES SHARED )

OPTIONS( BUILD_RULES EXECUTABLE "Option build target of ${PROJECT_NAME}" EXECUTABLE STATIC SHARED )

################################################################################
#
# 设置工具链
#

OPTIONS( TOOLCHAIN clang "Option toolchain" gcc clang arm mips riscv )

IF( ${TOOLCHAIN} MATCHES "clang" )
    INCLUDE( ${CMAKE_ROOT_LIST_DIR}/cmake/toolchain-clang.cmake )
ELSEIF( TOOLCHAIN MATCHES "arm" )
    INCLUDE( ${CMAKE_ROOT_LIST_DIR}/cmake/toolchain-arm.cmake )
ELSEIF( TOOLCHAIN MATCHES "riscv" )
    INCLUDE( ${CMAKE_ROOT_LIST_DIR}/cmake/toolchain-riscv.cmake )
ELSEIF( TOOLCHAIN MATCHES "mips" )
    INCLUDE( ${CMAKE_ROOT_LIST_DIR}/cmake/toolchain-mips.cmake )
ELSE()
    INCLUDE( ${CMAKE_ROOT_LIST_DIR}/cmake/toolchain-gcc.cmake )
ENDIF()

################################################################################
#
#  设置文件列表
#       GetFilesFromCurrentDir( ALL_FILE_LISTS )
#       GetFilesFromSpecifyDir( ALL_FILE_LISTS ${CMAKE_CURRENT_LIST_DIR} )

#       GetFilesFromCurrentDir( ALL_FILE_LISTS *.h *.hpp *.c *.cpp )
#       GetFilesFromSpecifyDir( ALL_FILE_LISTS ${CMAKE_CURRENT_LIST_DIR} *.h *.hpp *.c *.cpp )

#       GetFilesFromCurrentDir( ALL_FILE_LISTS main.hpp main.cpp )
#       GetFilesFromSpecifyDir( ALL_FILE_LISTS ${CMAKE_CURRENT_LIST_DIR} main.hpp main.cpp )

GetFilesFromCurrentDir( ALL_FILE_LISTS *.h *.hpp *.c *.cpp )

################################################################################
#
#  设置引用外部头件
#

SET( INCLUDE_DIRS ${INCLUDE_DIRS} )

################################################################################
#
#  设置引用外部库
#

SET( LINK_DIRS ${LINK_DIRS} )

SET( LINK_LIBS ${LINK_LIBS}
    pthread
    ha-brick
    dl
)

################################################################################
#
#  设置自定义宏
#

# ADD_DEFINITIONS( xxx )

SET( CMAKE_BASE_FLAGS 
)

IF( CMAKE_COMPILER_IS_GNUCC )
    SET( CMAKE_C_FLAGS   ${CMAKE_C_FLAGS}   ${CMAKE_BASE_FLAGS} )
ENDIF( CMAKE_COMPILER_IS_GNUCC )

IF( CMAKE_COMPILER_IS_GNUCXX )
    SET( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${CMAKE_BASE_FLAGS} )
ENDIF( CMAKE_COMPILER_IS_GNUCXX )

################################################################################
#
# 开始构建
#

INCLUDE( ${CMAKE_ROOT_LIST_DIR}/cmake/cmake_build.cmake )
